package com.falm.maker.cli.command;

import cn.hutool.core.bean.BeanUtil;
import com.falm.maker.entity.DataModel;
import com.falm.maker.generator.MainGenerator;
import lombok.Data;
import picocli.CommandLine;

import java.util.concurrent.Callable;

/**
 * @author Administrator
 */
@Data
@CommandLine.Command(name = "generate", version = "generate 1.0", mixinStandardHelpOptions = true)
public class GenerateCommand implements Callable<Integer> {

    @CommandLine.Option(names = {"-a", "--author"}, arity = "0..1", interactive = true, echo = true,prompt = "请输入作者名称",description = "作者名称")
    private String author = "falm";

    @CommandLine.Option(names = {"-l", "--loop"}, arity = "0..1", interactive = true, echo = true,prompt = "输入值是否需要循环(Y/N)",description = "是否开启循环")
    private boolean loop;

    @CommandLine.Option(names = {"-o", "--output"}, arity = "0..1", interactive = true, echo = true,prompt = "输出提示词",description = "输出语句")
    private String outputText;

    @Override
    public Integer call() {
        DataModel config = new DataModel();
        BeanUtil.copyProperties(this, config);
        MainGenerator.doGenerate(config);
        return 0;
    }
}
